﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LPV_POS.mh_pos.mh_doanhthu
{
    public partial class mh_baocaodoanhthu_TheTraTruoc : Form
    {
        public mh_baocaodoanhthu_TheTraTruoc()
        {
            InitializeComponent();
        }
        
        private void mh_baocaodoanhthu_TheTraTruoc_Load(object sender, EventArgs e)
        {
            dTuNGay.Value = new DateTime(Variable.ngay_gio_hienhanh.Year, Variable.ngay_gio_hienhanh.Month, Variable.ngay_gio_hienhanh.Day, 0, 0, 1);
            dDenNgay.Value = new DateTime(Variable.ngay_gio_hienhanh.Year, Variable.ngay_gio_hienhanh.Month, Variable.ngay_gio_hienhanh.Day, 23, 59, 59);

        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            DataTable tbTMP = new thuvien().SP_SelectDataTable("sp_DM_THE_TRA_TRUOC",
                                        new string[] { "@flag", "@NGAY_TU", "@NGAY_DEN", "@NAP_TIEN" },
                                        new object[] { 5, dTuNGay.Value, dDenNgay.Value, rbtNapTien.Checked });

            grdDM_NAP_TIEN.DataSource = tbTMP;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnExcel_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            string sfile = "";
            if (rbtNapTien.Checked)
                sfile = Application.StartupPath + "\\DS_The_Tra_Truoc_Nap_Tien" + Variable.ngay_gio_hienhanh.ToString("yyyyMMdd_HHmmss") + ".xls";
            else
                sfile = Application.StartupPath + "\\DS_The_Tra_Truoc_Tru_Tien" + Variable.ngay_gio_hienhanh.ToString("yyyyMMdd_HHmmss") + ".xls";
            grvDM_NAP_TIEN.ExportToExcelOld(sfile);
            if (System.IO.File.Exists(sfile))
                System.Diagnostics.Process.Start(sfile);
            this.Cursor = Cursors.Default;
        }

    }
}
